package com.zan.backend.exception;

import com.zan.backend.enums.CommonBaseErrorEnum;
import com.zan.backend.enums.BaseErrorEnum;
import lombok.Data;

/**
 * @Author Zan
 * @Create 2024/3/16 16:59
 * @Description :
 */
@Data
public class BusinessException extends RuntimeException{

    protected Integer errorCode;

    protected String errorMsg;

    public BusinessException(String errorMsg) {
        super(errorMsg);
        this.errorCode = CommonBaseErrorEnum.BUSINESS_ERROR.getErrorCode();
        this.errorMsg = errorMsg;
    }

    public BusinessException(Integer errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BusinessException(BaseErrorEnum baseErrorEnum) {
        super(baseErrorEnum.getErrorMsg());
        this.errorCode = baseErrorEnum.getErrorCode();
        this.errorMsg = baseErrorEnum.getErrorMsg();
    }
}
